package com.bruce.pattern.behavioral.interpreter;

import org.junit.Test;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;

/**
 * Created by bruce on 2018/11/10 17:50
 */
public class MainTest {

    @Test
    public void test() {
        ExpressionParser spelExpressionParser = new SpelExpressionParser();

        Expression expression = spelExpressionParser.parseExpression("100 * 2+400");

        Object value = expression.getValue();

        System.out.println(value);

    }

    @Test
    public void test2(){
        CalculatorExpressionParser parser = new CalculatorExpressionParser();
        Node parse = parser.parse("3 * 2 * 4 / 6 % 5");
        int interpret = parse.interpret();
        System.out.println(interpret);
    }


}
